package com.industrial.system.api.factory;

import com.industrial.common.core.domain.R;
import com.industrial.system.api.RemoteWhiteInfoService;
import com.industrial.system.api.domain.EmEnterpriseInformationCollection;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public class RemoteWhiteFallbackFactory implements FallbackFactory<RemoteWhiteInfoService> {

    @Override
    public RemoteWhiteInfoService create(Throwable throwable) {
        return new RemoteWhiteInfoService(){

            @Override
            public R<String> loadAdCodeToAdBaseId(String adCode) {
                return R.fail("获取用户失败:" + throwable.getMessage());
            }

            @Override
            public R<Boolean> preMuExistWhite(String uscc) {
                return R.fail("查询白名单信息失败:" + throwable.getMessage());
            }

            @Override
            public R<Boolean> savePreMuCompanyInfoToWhite(Map<String, Object> params) {
                return R.fail("保存失败:" + throwable.getMessage());
            }

            /**
             * @param uscc
             * @return
             */
            @Override
            public R<List<String>> preMuExistWhiteByUscc(List<String> uscc) {
                return R.fail("查询失败:" + throwable.getMessage());
            }

            @Override
            public R<EmEnterpriseInformationCollection> queryWhiteInfoByUscc(String uscc) {
                return R.fail("查询失败:" + throwable.getMessage());
            }

            /**
             * 查询行政区代码所对应的行政区ID
             *
             * @param codes
             * @return
             */
            @Override
            public R<Map<String, String>> queryWhiteAreaId(String codes) {
                return R.fail("查询失败:" + throwable.getMessage());
            }
        };
    }
}
